$(function () {
    share();
    var myLoading=new MyToast('.loadingToast',{content:'注册中...'});
    var inviteCode = $.getUrlParam('inviteCode')
    if (inviteCode) {
        $('input[name="invite"]').val(inviteCode).prop('readonly', true)
    }
    $('#registerBtn').click(function () {
        var username=$('input[name="username"]').val();
        var pwd=$('input[name="pwd"]').val();
        var phone=$('input[name="phone"]').val();
        var invite=$('input[name="invite"]').val();
        if(!username){
            $.Dialog({content:'用户名不能为空！'})
        }else if(!pwd){
            $.Dialog({content:'密码不能为空！'})
        }else  if(!phone){
            $.Dialog({content:'电话不能为空！'})
        }else if(!invite){
            $.Dialog({content:'邀请码不能为空！'})
        }
        else{
            myLoading.show();
            $.ajax({
                url:host+'/CMSAPI/registerPartner',
                type:'POST',
                data:{username:username,pwd:pwd,Phone:phone,AccountNumber:invite,cid:cid,openid:openid},
                dataType:'JSON',
                success:function (data) {
                    myLoading.hide();
                    if(data.state){
                        window.location.href='login.html';
                    }else {
                        $.Dialog({content:data.message})
                    }
                }
            })
        }
    })
})
